package amend;

import com.lijinjiang.beautyeye.BeautyEyeLNFHelper;

import javax.swing.*;
import java.awt.*;

/**
 * @ClassName Amend03_JTabbedPane
 * @Description 调整了 JTabbedPane 的显示样式
 * @Author Li
 * @Date 2022/8/29 17:27
 * @ModifyDate 2022/8/29 17:27
 * @Version 1.0
 */
public class Amend03_JTabbedPane {
    public static void main(String[] args) {
        try {
            /**
             * 设置本属性将改变窗口边框样式定义
             * 系统默认样式 : osLookAndFeelDecorated
             * 强立体半透明 : translucencyAppleLike
             * 弱立体半透明 : translucencySmallShadow
             * 普通不透明 : generalNoTranslucencyShadow
             */
            BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
            BeautyEyeLNFHelper.launchBeautyEyeLNF();
        } catch (Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame(); // 初始化窗口
        frame.setTitle("Amend03"); // 设置标题

        JTabbedPane tabbedPane = new JTabbedPane();
        String filename = JTabbedPane.class.getResource("/").getPath() + "images/close.png";
        ImageIcon icon = new ImageIcon(filename);
        icon.setImage(icon.getImage().getScaledInstance(20, 20, Image.SCALE_DEFAULT));

        tabbedPane.addTab(" 对象 ", new JPanel().add(new JLabel("这是首页")));
        JPanel panel = new JPanel();
        panel.setOpaque(false);
        panel.setLayout(new BorderLayout());
        JLabel title = new JLabel(" 对象 ");
        panel.add(title, BorderLayout.WEST);
        JLabel iconLabel = new JLabel();
        iconLabel.setIcon(icon);
        panel.add(iconLabel, BorderLayout.EAST);

        tabbedPane.setTabComponentAt(0, panel);

        tabbedPane.addTab(" 语文 ", new JPanel().add(new JLabel("这是语文选项卡页")));
        tabbedPane.addTab(" 数学 ", new JPanel().add(new JLabel("这是数学选项卡页")));
        tabbedPane.addTab(" 英语 ", new JPanel().add(new JLabel("这是英语选项卡页")));

        tabbedPane.setFocusable(false);

        frame.add(tabbedPane);

        frame.setSize(new Dimension(800, 600)); // 显示大小
        frame.setLocationRelativeTo(null); // 屏幕居中
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设置默认关闭方式
        frame.setVisible(true);

    }
}
